using System;
using System.Collections.Generic;
using System.Text;
using ENTITIES;
using DAL;
using Utility;

namespace BUS
{
  public  class TrangThaiBUS
    {
        public static void Insert(TBTrangThai tt)
        {
            TrangThaiDAL ttDAL = new TrangThaiDAL();
            ttDAL.Insert(tt);
        }
        public static void Update(TBTrangThai tt)
        {
            TrangThaiDAL ttDAL = new TrangThaiDAL();
            ttDAL.Update(tt);
        }
        public static void Delete(int iD)
        {
            TrangThaiDAL ttDAL = new TrangThaiDAL();
            ttDAL.Delete(iD);
        }
        public static tbTrangThaiCollection Get(string where,
            int pageindex,
            int pagesize,
            string orderby,
            string orderdirection,
            out int total)
        {
            TrangThaiDAL ttDAL = new TrangThaiDAL();
            return ttDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static tbTrangThaiCollection GetAll()
        {
            int total = 0;
            Criteria cri = new Criteria();
            TrangThaiDAL ttDAL = new TrangThaiDAL();
            return ttDAL.Get(cri.Criter, 0, 0, tbTrangThaiColumns.MaTT.ToString(), OrderDirection.ASC.ToString(), out total);
        }
        public static TBTrangThai GetByID(int iD)
        {
            int total = 0;
            Criteria cri = new Criteria();
            cri.add(Condition.AND, tbTrangThaiColumns.MaTT.ToString(), Condition.EQUAL, iD);
            TrangThaiDAL ttDAL = new TrangThaiDAL();
            tbTrangThaiCollection trangthaicollection = ttDAL.Get(cri.Criter,
                  0, 0, tbTrangThaiColumns.MaTT.ToString(), OrderDirection.ASC.ToString(), out total);
            if (trangthaicollection.Count > 0)
                return trangthaicollection[0];
            return null;
        }
        public static tbTrangThaiCollection GetLimited(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            TrangThaiDAL ttDAL = new TrangThaiDAL();
            return ttDAL.Get(cri.Criter, 1, number,
             tbTrangThaiColumns.MaTT.ToString(), OrderDirection.DESC.ToString(), out total);
        }
        public static tbTrangThaiCollection GetPromotion(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            TrangThaiDAL ttDAL = new TrangThaiDAL();
            return ttDAL.Get(cri.Criter, 1, number,
               tbTrangThaiColumns.MaTT.ToString(), OrderDirection.DESC.ToString(), out total);
        }
    }
    }

